package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.request.*;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.MemberUserGetVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.MemberUserQueryVO;
import com.ssy.lingxi.member.merchant.service.web.IPlatformMemberUserService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 平台后台-权限管理-用户管理
 * @author 万宁
 * @version 2.0.0
 * @date 2020-06-29
 */
@RestController
@RequestMapping("/member/manage/user")
public class PlatformMemberUserController {
    @Resource
    private IPlatformMemberUserService platformMemberUserService;

    /**
     * 新增会员用户
     * @param headers HttpHeaders信息
     * @param memberUserVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/add")
    public Wrapper<Void> addMemberUser(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUserAddVO memberUserVO) {
        return platformMemberUserService.addMemberUser(headers, memberUserVO);
    }

    /**
     * 查询用户信息
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<MemberUserGetVO> getMemberUser(@RequestHeader HttpHeaders headers, @Valid MemberUserIdVO idVO) {
        return platformMemberUserService.getMemberUser(headers, idVO);
    }

    /**
     * 修改会员用户
     * @param headers HttpHeaders信息
     * @param memberUserVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/update")
    public Wrapper<Void> updateMemberUser(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUserUpdateVO memberUserVO) {
        return platformMemberUserService.updateMemberUser(headers, memberUserVO);
    }

    /**
     * 删除会员用户
     * @param headers HttpHeaders信息
     * @param memberUserIdVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/delete")
    public Wrapper<Void> deleteMemberUser(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUserIdVO memberUserIdVO) {
        return platformMemberUserService.deleteMemberUser(headers, memberUserIdVO);
    }

    /**
     * 更改用户状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/updatestatus")
    public Wrapper<Void> updateMemberUserStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberUserUpdateStatusVO statusVO) {
        return platformMemberUserService.updateMemberUserStatus(headers, statusVO);
    }

    /**
     * 分页查询会员用户
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberUserQueryVO>> pageMemberUser(@RequestHeader HttpHeaders headers, @Valid PageQueryMemberUserVO pageVO) {
        return platformMemberUserService.pageMemberUser(headers, pageVO);
    }
}
